package com.inet.Test06;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy;
import java.util.concurrent.TimeUnit;

/**
 * @Author weijingchen
 * @Date 2025/6/26 15:15
 * @Version 1.0.0
 */
public class Server {
    public static void main(String[] args) throws IOException {


        ThreadPoolExecutor pool = new ThreadPoolExecutor(5,
                10,
                1000,
                TimeUnit.MILLISECONDS,
                new ArrayBlockingQueue<>(5),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy());
        ServerSocket ss = new ServerSocket(10301);
        while (true) {
            Socket socket = ss.accept();
            System.out.println("连接成功");
            //开启一条线程
            pool.submit(new MyRunnable(socket));
        }
    }
}
